[fix/MAT-524] 필기 자동저장 race 로 인한 백엔드 빈 PUT 회귀 fix#312
Open
b0nsu wants to merge 2 commits intofix/mat-349-handwriting-api-cache-strategyfrom
Open
[fix/MAT-524] 필기 자동저장 race 로 인한 백엔드 빈 PUT 회귀 fix#312b0nsu wants to merge 2 commits intofix/mat-349-handwriting-api-cache-strategyfrom
b0nsu wants to merge 2 commits intofix/mat-349-handwriting-api-cache-strategyfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- race 가드 ref 3개 (appliedScrapIdRef, pendingLoadRef, needsSaveRef) — 데이터 적용 전 PUT 차단
- pure helper (evaluateFlush, canMark) 매니저 inline — race 가드 dispatch
- autosave fire-and-forget / 명시 flush mutateAsync + 5s timeout (silent, 실패 시 toast)
- decode 실패 시 전화면 에러 + PUT 차단
- key={drawing-canvas-\${scrapId}} 제거, 매니저 imperative reset
- canvas mount: callback ref + boolean state (drawing.tsx useImperativeHandle deps 없는 문제 우회)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
60076ec to
af8a7d7
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a regression where introducing staleTime: Infinity caused a handwriting autosave race, leading to empty PUT requests overwriting existing backend handwriting data during fast tab/scrap switching in ScrapDetailScreen.
Changes:
- Reworked handwriting autosave to guard against pre-load PUTs using screen-scoped refs (
appliedScrapIdRef,pendingLoadRef,needsSaveRef) and explicitflushPending()semantics. - Removed
DrawingCanvasremount-by-key and moved canvas reset/attachment into the handwriting manager via an imperative callback ref. - Added a decode-failure UI state that blocks saving and forces an explicit back navigation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| apps/native/src/features/student/scrap/screens/ScrapDetailScreen.tsx | Switches to the new handwriting manager API (flush + canvas ref callback), adds decode error screen, and removes key-based canvas remounting. |
| apps/native/src/features/student/scrap/hooks/useHandwritingManager.ts | Implements race-guarded load/apply, autosave interval, explicit flush with timeout, and local mutation/cache updates for handwriting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- flushPending Promise<boolean> → Promise<void> (호출부 ok 가드 3곳 제거) - autosave fire-and-forget 실패 시 needsSaveRef 복구 — 다음 interval 에 재시도 - 자동저장 토스트 제거, 명시 flush 토스트만 유지 (이중 토스트 방지) - inline useMutation 제거, useUpdateHandwriting 재사용 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
b0nsu
added a commit
that referenced
this pull request
May 5, 2026
5초 autosave 메인 스레드 4단계 직렬화(stringify → encodeURIComponent
→ unescape → btoa)를 1단계(JSON.stringify)로 축소.
handwritingEncoder
- canonicalize: Stroke / Point / TextItem 의 키 순서를 명시 재구성하여
byte-stable JSON 출력 보장 (동일 입력 → 동일 출력).
- decodeHandwritingData: 응답 객체만 받는 단일 시그니처. dataJson 우선,
없으면 data(base64) fallback, 둘 다 없으면 빈값. 옛 strokes-only
배열 형식 호환 유지.
useHandwritingManager
- PUT body 를 { dataJson } 으로 (data 미포함) — 자연 마이그레이션.
- 응답 분기를 decodeHandwritingData(handwritingData) 로 단순화.
Stacked on PR #312 — base: fix/mat-524-autosave-data-loss.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
handwriting autosave race 봉쇄. 빠른 탭 전환 시 빈 PUT 으로 백엔드 데이터를 덮어쓰던 regression 해결.
Linear
Changes
Testing
Risk / Impact
Follow-ups
Screenshots / Video
(필요 시)